import pika
import requests
import pickle
from RabbitDemo.RabbitMQClass import get_connection

MAX_PRIORITY = 100
TOTAL = 10
QUEUE_NAME = 'scrape_queue'

connection=get_connection()
channel=connection.channel()
channel.queue_declare(queue=QUEUE_NAME,durable=True)
for i in range(1,TOTAL+1):
    url=f'https://ssr1.scrape.center/detail/{i}'
    request=requests.Request('GET',url)
    channel.basic_publish(exchange='',routing_key=QUEUE_NAME,
                      properties=pika.BasicProperties(priority=int(i), delivery_mode=2),
                          body=pickle.dumps(request)
                          )
    print(f'新增request url {url}')